<!--
 * @Description: 
 * @Version: 1.0
 * @Author: Will
 * @Date: 2023-03-07 17:21:40
 * @LastEditors: MarsLay 331412466@qq.com
 * @LastEditTime: 2023-11-24 14:48:13
 * @FilePath: \cloud-space\components\tree\tree-item.vue
 * Copyright (C) 2023 Will. All rights reserved.
-->
<template>
  <view class="tree-item">
    <view class="lists">
      <block v-for="item in list" :key="item.id">
        <label class="label">
          <view class="value" @click.stop="changeShow(item)">
            <image :style="{ opacity: item.child && item.child.length > 0 ? 1 : 0 }" :src="img[item.isShow ? 1 : 0]" mode="aspactFill"></image>
            {{ item[mate] }}
          </view>
          <view>
            <checkbox :value="String(item.id)" :checked="item.checked" />
          </view>
        </label>
        <l-tree-item v-show="item.isShow" :list.sync="item.child"></l-tree-item>
      </block>
    </view>
  </view>
</template>

<script>
import lTreeItem from "./l-tree-item.vue";
export default {
  components: { lTreeItem },
  name: "l-tree-item",
  props: {
    list: {
      type: Array,
      default: () => [],
    },
    mate: {
      type: String,
      default: "title",
    },
  },
  data() {
    return {
      img: ["../../static/img/icon/arrow-s.png", "../../static/img/icon/arrow-down-2.png"],
    };
  },
  watch: {},
  created() {},
  methods: {
    changeShow(v) {
      v.isShow = !v.isShow;
    },
  },
};
</script>

<style lang="less" scoped>
.lists {
  background: #fff;
  padding: 0 0 0 30upx;
}

.checkbox,
.radio {
  .label {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 10upx 0;
    .border-1px(bottom);

    .value {
      display: flex;
      flex-direction: row;
      align-items: center;
      font-size: 30upx;
      width: 50%;

      image {
        width: 24upx;
        height: 24upx;
        margin-right: 10upx;
      }
    }
  }
}
/deep/ .uni-checkbox-wrapper {
  margin-top: -8upx;
}
</style>
